package com.dgut.smart_house.util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DataUtil {
    public static String Data2StringByDay(int dayNum) {
        Date date = new Date(System.currentTimeMillis() - dayNum * 24 * 60 * 60 * 1000);
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sf.format(date).toString();
    }

    public static String Data2StringByHour(int hourNum) {
        Date date = new Date(System.currentTimeMillis() - hourNum * 60 * 60 * 1000);
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sf.format(date).toString();
    }
}
